<?php
/**
 * Created by PhpStorm.
 * User: Da Xiong
 * Date: 2018/12/29
 * Time: 13:42
 */

namespace App\Http\Controllers\v3;


use App\Models\LogTimes;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;

class LogTimeController extends Controller
{
    /**
     * 统计响应时间
     * @return \Illuminate\Http\JsonResponse
     */
    public function index(){
        try{
            $params = [
            'start_time' => request('start'),
            'end_time' => request('end'),
            'openid' => request('openid',''),
            'action' => request('action','')
            ];
            $params['count_time'] = $params['end_time'] - $params['start_time'];
            $params['created_at'] = Carbon::now();
            LogTimes::create($params);
            return $this->returnJson(0,'ok');
        }catch (\Exception $e){
            Log::error($e->getMessage());
            return $this->returnJson(1,'服务器内部出错啦');
        }

    }
}
